import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void orderArray(int[] array){
        for(int i = 0; i < array.length; i++){
            array[i] = i;
        }
    }
    public static void notOrderArray(int[] array){
        for(int i = 0; i < array.length; i++){
            array[i] = array.length-i;
        }
    }
    public static void notOrderArrayRandom(int[] array){
        Random random = new Random();
        for(int i = 0; i < array.length; i++){
            array[i] = random.nextInt(10_000);
        }
    }
    public static void testInserSort(int[] array){
        int[] tmp = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.insertSort(tmp);
        long endTime = System.currentTimeMillis();
        System.out.println("插入排序耗时："+(endTime-startTime));//673

        long startTime1 = System.currentTimeMillis();
        Sort.shellSort(tmp);
        long endTime1 = System.currentTimeMillis();
        System.out.println("希尔排序："+(endTime1-startTime1));//7


        long startTime2 = System.currentTimeMillis();
        Sort.selectSort(tmp);
        long endTime2 = System.currentTimeMillis();
        System.out.println("选择排序："+(endTime2-startTime2));//773

        long startTime3 = System.currentTimeMillis();
        Sort.heapSort(tmp);
        long endTime3 = System.currentTimeMillis();
        System.out.println("堆排序："+(endTime3-startTime3));//11



    }

    public static void main(String[] args) {
        int[] array = {1,25,3,4,21,5,6,9,18};
        /*System.out.println(Arrays.toString(array));
        Sort.mergeSort(array);
        System.out.println(Arrays.toString(array));*/
        System.out.println(Arrays.toString(array));
        Sort.countSort(array);
        System.out.println(Arrays.toString(array));

        /*System.out.println(Arrays.toString(array));
        Sort.mergeSoreNor(array);
        System.out.println(Arrays.toString(array));*/

    }

    public static void main2(String[] args) {
        int[] array = new int[10_0000];
        notOrderArrayRandom(array);//662
        //notOrderArray(array);//1165
        //orderArray(array);//4
        testInserSort(array);
        Sort.shellSort(array);
    }
    public static void main1(String[] args) {
        int[] array = {27,0,8,0,4,2};
        Sort.quickSort(array);
        //Sort.bubbleSort(array);
        //Sort.selectSort2(array);
        //Sort.insertSort(array);
        System.out.println(Arrays.toString(array));//[0, 0, 2, 4, 8, 27]
    }
}
